package leetcode.每日一题;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/11/6 10:18 PM
 * @description：
 */
public class 设计Goal解析器 {

    @Test
    public void test() {
        System.out.println(new Solution().interpret("(al)G(al)()()G"));
    }

    class Solution {
        public String interpret(String command) {
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < command.length(); i++) {
                char ch = command.charAt(i);
                switch (ch) {
                    case 'G':
                        builder.append("G");
                        break;
                    case '(':
                        if (command.charAt(i + 1) == ')') {
                            builder.append("o");
                            i++;
                        } else {
                            builder.append("al");
                            i += 3;
                        }
                }
            }
            return builder.toString();
        }
    }
}
